function add_lifewall_view() {
	$("#main-content-body").html("");
	$("#main-content-body").append("<p><span><label for='lifewall_title' class='label'>标题</label></span><span class='title'><input type='text' name='lifewall_title' id='lifewall_title' style='height:33px; border:1px solid #EEEEEE; width:600px;' /></span></p><br class='spacer' />");
    $("#main-content-body").append("<p><span><label for='lifewall_content' class='label'>内容</label></span><span style='height:300px;'><textarea rows='15' cols='80' style='border:1px solid #EEEEEE;resize:none;'></textarea></span><br class='spacer' /></p><br class='spacer' />");
	$("#main-content-body").append("<p><span><label for='lifewall_mood' class='label'>表情</label></span><span><select id='lifewall_mood' name='lifewall_mood' style='display:block; width:200px;'><option>1</option><option>2</option><option>3</option></select></span></p>");
	$("#main-content-body").append("<p><span name='button' style='width:100px; margin-left:130px; cursor:pointer; background:#EEEEEE;'>添加</span></p>");
	$("#main-content-body span[name='button']").bind("click", admin_add_lifewall);
}

function admin_add_lifewall() {
	var lifewall_title = $("#main-content-body input[name='lifewall_title']").val();
	var lifewall_content = $("#main-content-body textarea").val();
	var lifewall_mood = $("#main-content-body select").val();
	$("#main-content-body span[name='button']").html("保存中...").css("cursor","text").unbind("click");
	$.post("add_lifeWall", { lifeWallTitle:lifewall_title, lifeWallContent:lifewall_content, lifeWallMood:lifewall_mood}, function(data) {
		$("#main-content-body span[name='button']").html("添加").css("cursor","pointer").bind("click", admin_add_lifewall);
	});
}

function query_lifewall_page(pageNo) {
	var pageSize = 10;
	var pageCount;
	var msgArray;
	var resultArray;
	var dataArray;
	var rowCount;

	$.getJSON("query_lifeWall_page", {beginIndex:(pageNo-1)*pageSize,count:pageSize}, function(data) {
		msgArray = eval("("+data.msg+")");
		resultArray = msgArray.result;
		if(resultArray[0].resultMsg == "success") {
			rowCount = resultArray[0].rowCount;
			pageCount = Math.ceil(rowCount/pageSize);
			if(pageCount == 0) {
				pageCount = 1;
			}
			dataArray = msgArray.data;
			$("#main-content-body").html("");
			$("#main-content-body").append("<p><span class='title' style='width:500px;'>标题</span><span class='time'>时间</span><span class='edit'>操作</span></p><hr class='spacer' />");
			$.each(dataArray, function(i, item) {
				$("#main-content-body").append("<p><span class='title' style='width:500px;'>"+item.title+"</span><span class='time'>"+item.time+"</span><span class='edit'><label>操作</label></span></p><br class='spacer' />");
			});
			$("#main-content-footer").html("<ul><li style='width:60px;'><span class='pageSelect' value='1'>首页</span></li><li style='width:60px;'><span class='pageSelect' value='"+parseInt(pageNo-1)+"'>上一页</span></li><li style='width:60px;'><span class='pageSelect' value='"+parseInt(parseInt(pageNo)+1)+"'>下一页</span></li><li style='width:60px;'><span class='pageSelect' value='"+pageCount+"'>末页</span></li><li>共<span>"+rowCount+"</span>条记录</li><li>每页"+pageSize+"条</li><li>当前<span>"+pageNo+"</span>/<span>"+pageCount+"</span>页</li></ul><br class='spacer' />");
			$("#main-content-footer .pageSelect").each(function(i, item) {
				$(this).click(function() {
					var tempPageNo = $(this).attr("value");
					if(tempPageNo>pageCount) {
						pageNo = pageCount;
					} else if(tempPageNo<1) {
						pageNo = 1;
					} else {
						query_lifewall_page(tempPageNo);
					}
				});
			});
		} else {
			$("#main-content-body").html(resultArray[0].errorMsg);
		}
	});
}